package com.hx.jvm.jvm.tool;

import java.util.ArrayList;

/**
 * JVM参数: -Xms100M  -Xmx100M
 *
 * @author jxrjc
 * 打开JConsole控制台查看
 */

public class JConsole {

    public static void main(String[] args) throws Exception {
        fillHeap(1000);
    }


    public static void fillHeap(int num) throws Exception {
        ArrayList<OOMObject> list = new ArrayList<OOMObject>();
        for (int i = 0; i < num; i++) {
            Thread.sleep(1000);
            list.add(new OOMObject());
        }
        System.gc();
    }

    static class OOMObject {
        public byte[] placeholder = new byte[64 * 1024];
    }
}
